//
//  XFBottomView.m
//  SinaBlog_OC
//
//  Created by macs on 15/11/17.
//  Copyright © 2015年 BlackTail. All rights reserved.
//

#import "XFBottomView.h"
#import "UIView+XFGetNavgation.h"
#import "XFTempViewController.h"

@interface XFBottomView ()
@property(nonatomic, weak) UIButton *retweeteBtn;
@property(nonatomic, weak) UIButton *commentBtn;
@property(nonatomic, weak) UIButton *lickBtn;
@property(nonatomic, weak) UIView *sepView1;
@property(nonatomic, weak) UIView *sepView2;
@end

@implementation XFBottomView

- (void)retweeteBtnDidClick {

  UINavigationController *nav = [self.retweeteBtn getNavgationController];

  XFTempViewController *temp = [[XFTempViewController alloc] init];
  [nav pushViewController:temp animated:YES];
}

// 1.重写 init 方法

- (instancetype)initWithFrame:(CGRect)frame {

  if (self = [super initWithFrame:frame]) {
    [self setupUI];
    [self setupFrame];
  }
  return self;
}

// 2. setupUI添加子控件
- (void)setupUI {
  self.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1];
  UIButton *retweeteBtn =
      [[UIButton alloc] initWithTitle:@"转发"
                                Color:[UIColor lightGrayColor]
                               BgIcon:nil
                                Image:@"timeline_icon_retweet"];
  [self addSubview:retweeteBtn];
  self.retweeteBtn = retweeteBtn;
  self.retweeteBtn.titleLabel.font = [UIFont systemFontOfSize:10];

  [self.retweeteBtn addTarget:self
                       action:@selector(retweeteBtnDidClick)
             forControlEvents:UIControlEventTouchUpInside];

  UIButton *commentBtn =
      [[UIButton alloc] initWithTitle:@"评论"
                                Color:[UIColor lightGrayColor]
                               BgIcon:nil
                                Image:@"timeline_icon_comment"];
  [self addSubview:commentBtn];
  self.commentBtn = commentBtn;
  self.commentBtn.titleLabel.font = [UIFont systemFontOfSize:10];
  UIButton *lickBtn = [[UIButton alloc] initWithTitle:@"赞"
                                                Color:[UIColor lightGrayColor]
                                               BgIcon:nil
                                                Image:@"timeline_icon_unlike"];
  [self addSubview:lickBtn];
  self.lickBtn = lickBtn;
  self.lickBtn.titleLabel.font = [UIFont systemFontOfSize:10];

  UIView *sepView1 = [[UIView alloc] init];
  sepView1.backgroundColor = [UIColor lightGrayColor];

  [self addSubview:sepView1];
  self.sepView1 = sepView1;
  UIView *sepView2 = [[UIView alloc] init];
  sepView2.backgroundColor = [UIColor lightGrayColor];
  [self addSubview:sepView2];
  self.sepView2 = sepView2;
}

// 3. setupFrame添加子控件约束
- (void)setupFrame {
  [self.retweeteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.mas_left);
    make.top.equalTo(self.mas_top);
    make.height.equalTo(self.mas_height);

  }];
  [self.sepView1 mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.retweeteBtn.mas_right);
    make.centerY.equalTo(self.retweeteBtn.mas_centerY);
    make.height.equalTo(self.mas_height).multipliedBy(0.6);
    make.width.equalTo(@0.8);
  }];
  [self.commentBtn mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.retweeteBtn.mas_right);
    make.top.equalTo(self.mas_top);
    make.height.equalTo(self.mas_height);
    make.width.equalTo(self.retweeteBtn.mas_width);
  }];
  [self.sepView2 mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.commentBtn.mas_right);
    make.centerY.equalTo(self.retweeteBtn.mas_centerY);
    make.height.equalTo(self.mas_height).multipliedBy(0.6);
    make.width.equalTo(@0.8);
  }];
  [self.lickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
    make.left.equalTo(self.commentBtn.mas_right);
    make.top.equalTo(self.mas_top);
    make.height.equalTo(self.mas_height);
    make.width.equalTo(self.retweeteBtn.mas_width);
    make.right.equalTo(self.mas_right);
  }];
}

@end
